package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.SubscribeMapper;
import com.wanmait.recruitment.pojo.Subscribe;
import com.wanmait.recruitment.pojo.Userinfo;
import com.wanmait.recruitment.service.SubscribeService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class SubscribeServiceImpl implements SubscribeService {
    @Resource
    private SubscribeMapper subscribeMapper;

    @Override
    @CacheEvict(value = "subscribeCache",allEntries = true)
    public void insert(Subscribe subscribe) {
        subscribeMapper.insertSelective(subscribe);
    }

    @Override
    @CacheEvict(value = "subscribeCache",allEntries = true)
    public void delete(Integer id) {
        subscribeMapper.deleteById(id);
    }

    @Override
    public void delete(String ids) {

    }

    @Override
    @CacheEvict(value = "subscribeCache",allEntries = true)
    public void update(Subscribe subscribe) {
        subscribeMapper.updateByPrimaryKey(subscribe);
    }

    @Override
    public Subscribe findById(Integer id) {
        return null;
    }

    @Override
    public List<Subscribe> findAll() {
        return null;
    }

    @Override
    public List<Subscribe> findAll(Subscribe object) {
        return null;
    }

    @Override
    public PageInfo<Subscribe> findPage(int pageNum, int pageSize) {
        return null;
    }

    @Override
    @Cacheable("subscribeCache")
    public List<Subscribe> findAllByUserinfo(Userinfo userinfo) {
        return subscribeMapper.selectByUserinfo(userinfo);
    }

    @Override
    public Integer findSubscribeCount() {
        return subscribeMapper.selectSubscribeCount();
    }
}
